using System;
using System.Globalization;
using System.Linq;
using System.Web.Mvc;

namespace Excuse.Infrastructure
{
    public class BaseController : Controller
    {
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            if(RouteData.Values != null)
            {
                var valuePair= RouteData.Values.First();

                if (valuePair.Value != null)
                {
                    var culture = valuePair.Value.ToString();

                    if (!string.IsNullOrEmpty(culture))
                    {
                        try
                        {
                            CultureInfo cultureI = new CultureInfo(culture);
                            System.Threading.Thread.CurrentThread.CurrentUICulture = cultureI;
                        }
                        catch (Exception ex)
                        {
                           // throw;
                        }
                    }
                }
                
            }
        }
    }
}